#!/usr/bin/env python
#
# Copyright 2007 Google Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

# import app engine stuff
from google.appengine.ext import webapp
from google.appengine.ext.webapp import util
from google.appengine.ext.webapp import template
from google.appengine.ext.webapp.util import run_wsgi_app

try:
  from gapycdn.gaecdn import ManageHandler
  from gapycdn.gaecdn import UploadHandler
  from gapycdn.gaecdn import ServeHandler
  from gapycdn.gaecdn import DeleteHandler
  from gapycdn.gaecdn import IndexHandler
  from gapycdn.gaecdn.CONFIG import *
  from gapycdn.gaecdn import CreateDirectoryHandler
except:
  from gaecdn import ManageHandler
  from gaecdn import UploadHandler
  from gaecdn import ServeHandler
  from gaecdn import DeleteHandler
  from gaecdn import IndexHandler
  from gaecdn.CONFIG import *
  from gaecdn import CreateDirectoryHandler

def main():
  application = webapp.WSGIApplication([
                (GAPYCDN_CONFIG["base_url"] + 'manage', ManageHandler.ManageHandler),
                (GAPYCDN_CONFIG["base_url"] + 'upload', UploadHandler.UploadHandler),
                (GAPYCDN_CONFIG["base_url"] + 'asset/(.+)', ServeHandler.ServeHandler),
                (GAPYCDN_CONFIG["base_url"] + 'delete', DeleteHandler.DeleteHandler),
                (GAPYCDN_CONFIG["base_url"] + "createdirectory", CreateDirectoryHandler.CreateDirectoryHandler),
                (GAPYCDN_CONFIG["base_url"], IndexHandler.IndexHandler)
	    ], debug=True)
  run_wsgi_app(application)


if __name__ == '__main__':
  main()
